package com.xmotor.test_AmqpTemplate.handler;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;

import java.time.LocalDateTime;

/**
 * @Description 测试AmqpTemplate处理器
 * @Author Dang Xianyue
 * @Date 2020-08-17 14:32
 * @Version 1.0
 */
//@Component
public class TestAmqpTemplateHandler {
    @Autowired
    private AmqpTemplate amqpTemplate;

    public void send(String msg) {
        this.amqpTemplate.convertAndSend("wsj.queue", msg);
        System.out.println("sendTime: "+ LocalDateTime.now());
    }

    @RabbitListener(queues = "wsj.queue")
    public void receiveQueue(String text) {
        System.out.println("接受到：" + text);
        System.out.println("receiveTime: "+LocalDateTime.now());
    }
}
